package com.app.biz.service.impl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import com.app.biz.dto.BizIndustrialElectricityConsumptionFormalDto;
import com.app.biz.dto.YearDto;
import com.app.common.core.domain.AjaxResult;
import com.app.common.utils.bean.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.app.biz.mapper.BizIndustrialElectricityConsumptionFormalMapper;
import com.app.biz.domain.formal.BizIndustrialElectricityConsumptionFormal;
import com.app.biz.service.IBizIndustrialElectricityConsumptionFormalService;


/**
 * 工业用电量正式(新)Service业务层处理
 *
 * @author SangGuangCan
 * @date 2024-01-22
 */
@Service
public class BizIndustrialElectricityConsumptionFormalServiceImpl implements IBizIndustrialElectricityConsumptionFormalService
{
    @Autowired
    private BizIndustrialElectricityConsumptionFormalMapper bizIndustrialElectricityConsumptionFormalMapper;

    /**
     * 查询工业用电量正式(新)
     *
     * @param baseId 工业用电量正式(新)主键
     * @return 工业用电量正式(新)
     */
    @Override
    public BizIndustrialElectricityConsumptionFormal selectBizIndustrialElectricityConsumptionFormalByBaseId(String baseId)
    {
        return bizIndustrialElectricityConsumptionFormalMapper.selectBizIndustrialElectricityConsumptionFormalByBaseId(baseId);
    }

    /**
     * 查询工业用电量正式(新)列表
     *
     * @param bizIndustrialElectricityConsumptionFormal 工业用电量正式(新)
     * @return 工业用电量正式(新)
     */
    @Override
    public List<BizIndustrialElectricityConsumptionFormal> selectBizIndustrialElectricityConsumptionFormalList(BizIndustrialElectricityConsumptionFormal bizIndustrialElectricityConsumptionFormal)
    {
        BizIndustrialElectricityConsumptionFormalDto dto = new BizIndustrialElectricityConsumptionFormalDto();
        BeanUtils.copyProperties(bizIndustrialElectricityConsumptionFormal,dto);
        Date year = dto.getYear();
        if (year != null) {
            SimpleDateFormat formatter = new SimpleDateFormat("yyyy");
            String filterYear = formatter.format(year);
            dto.setFilterYear(Integer.parseInt(filterYear));
        }
        return bizIndustrialElectricityConsumptionFormalMapper.selectBizIndustrialElectricityConsumptionFormalList(dto);
    }

    /**
     * 新增工业用电量正式(新)
     *
     * @param bizIndustrialElectricityConsumptionFormal 工业用电量正式(新)
     * @return 结果
     */
    @Override
    public int insertBizIndustrialElectricityConsumptionFormal(BizIndustrialElectricityConsumptionFormal bizIndustrialElectricityConsumptionFormal)
    {
        return bizIndustrialElectricityConsumptionFormalMapper.insertBizIndustrialElectricityConsumptionFormal(bizIndustrialElectricityConsumptionFormal);
    }

    /**
     * 修改工业用电量正式(新)
     *
     * @param bizIndustrialElectricityConsumptionFormal 工业用电量正式(新)
     * @return 结果
     */
    @Override
    public int updateBizIndustrialElectricityConsumptionFormal(BizIndustrialElectricityConsumptionFormal bizIndustrialElectricityConsumptionFormal)
    {
        return bizIndustrialElectricityConsumptionFormalMapper.updateBizIndustrialElectricityConsumptionFormal(bizIndustrialElectricityConsumptionFormal);
    }

    /**
     * 批量删除工业用电量正式(新)
     *
     * @param baseIds 需要删除的工业用电量正式(新)主键
     * @return 结果
     */
    @Override
    public int deleteBizIndustrialElectricityConsumptionFormalByBaseIds(String[] baseIds)
    {
        return bizIndustrialElectricityConsumptionFormalMapper.deleteBizIndustrialElectricityConsumptionFormalByBaseIds(baseIds);
    }

    /**
     * 删除工业用电量正式(新)信息
     *
     * @param baseId 工业用电量正式(新)主键
     * @return 结果
     */
    @Override
    public int deleteBizIndustrialElectricityConsumptionFormalByBaseId(String baseId)
    {
        return bizIndustrialElectricityConsumptionFormalMapper.deleteBizIndustrialElectricityConsumptionFormalByBaseId(baseId);
    }

    /**
     * 查询库中的日期
     *
     * @return
     */
    @Override
    public AjaxResult queryRq() {
        List<Integer> r = bizIndustrialElectricityConsumptionFormalMapper.queryRq();
        return AjaxResult.success(r);
    }
}
